/**
 * mutations
 */
export default {
    showLoading(state, txt = "正在加载") {
        state.showLoadingConfig.isShowLoading = true;
        state.showLoadingConfig.loadingText = txt;
    },
    hideLoading(state) {
        state.showLoadingConfig.isShowLoading = false;
    },
    showPreviewImage(state, config) {
        if (Array.isArray(config.urls)) {
            state.previewImageConfig.urls = config.urls;
            state.previewImageConfig.current = config.current;
            state.previewImageConfig.isShowPreviewImage = true;
        } else {
            throw new Error("预览图片地址不符合规范，必须是数组");
            return;
        }
    },
    hidePreviewImage(state) {
        state.previewImageConfig.isShowPreviewImage = false;
    },
    showActionSheet(state, config) {
        if (config && Array.isArray(config.itemList)) {
            state.actionSheetConfig.itemList = config.itemList;
            if (typeof config.success == "function") {
                state.actionSheetConfig.successCallBack = config.success;
            }
            state.actionSheetConfig.isShowActionSheet = true;
        } else {
            throw new Error("ShowAction的itemList必须是一个数值");
            return;
        }
    },
    hideActionSheet(state) {
        state.actionSheetConfig.isShowActionSheet = false;
        state.actionSheetConfig.itemList = [];
    }
}